// createRouter:作用是创建路由实例
// createWebHistory:作用是创建histroy模式下的路由
import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/Home/index.vue'
import Layout from '@/views/Layout/index.vue'
import BasicBar from '@/views/bar/BasicBar.vue'
import BasicPie from '@/views/pie/BasicPie.vue'
import BasicLine from '@/views/line/BasicLine.vue'
import MultiValueBar from '@/views/bar/MultiValueBar.vue'
import MixedLineAndBar from '@/views/bar/MixedLineAndBar.vue'

// 1. 创建路由实例
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  //2. 配置一些路由
  // 每个路由都需要映射到一个组件
  // path和component对应关系的位置
  routes: [
    //一级路由
    {
      path: '/',
      component: Layout,
      children: [
        // 二级路由
        //小技巧：二级路由路径置空，当访问一级路由时，二级路由组件也会得到渲染
        {
          path: '',
          component: Home
        },
        //二级路由
        {
          path: 'basicbar',
          component: BasicBar
        },
        {
          path: 'mixedlineandbar',
          component: MixedLineAndBar
        },
        {
          path: "multivaluebar",
          component: MultiValueBar
        },
        {
          path: "basicpie",
          component: BasicPie
        },
        {
          path: "basicline",
          component: BasicLine
        }
      ]
    }
  ]
})

// 将创建的路由实例暴露出去
export default router